//
//  StatusForwardCell.swift
//  WeiBo09
//
//  Created by 裘明 on 15/9/16.
//  Copyright © 2015年 qm. All rights reserved.
//

import UIKit
/// 转发微博的cell
class StatusForwardCell: StatusCell {
    
    override var statusViewModel: StatusViewModel? {
        didSet {
            
            forwardLabel.text = statusViewModel?.forwardText
        }
    }
    
    override func setupUI() {
        super.setupUI()
        
        // 1.添加控件
        contentView.insertSubview(backButten, belowSubview: pictureView)
        contentView.insertSubview(forwardLabel, aboveSubview: backButten)
        
        // 2.设置约束
        // 2.1> 背景按钮
        backButten.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -statusCellMargin, y: statusCellMargin))
        backButten.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        
        // 2.2> 转发文字
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButten, size: nil, offset: CGPoint(x: statusCellMargin, y: statusCellMargin))
        
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size: CGSize(width: statusCellPictureMaxWidth, height: statusCellPictureMaxWidth), offset: CGPoint(x: 0, y: statusCellMargin))
        pictureViewWidthCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        
        pictureViewHightCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        
        pictureViewTopCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)

        
    }
    
    // MARK: - 懒加载
    private lazy var backButten: UIButton = {
       let btn = UIButton()
        btn.backgroundColor = UIColor(white: 0.95, alpha: 1.0)
        
        return btn
    }()
    
    private lazy var forwardLabel: UILabel = UILabel(title: "转发微博转发微博转发微博转发微博转发微博转发微博", color: UIColor.darkGrayColor(), fontSize: 14, layoutWidth: UIScreen.mainScreen().bounds.width - 2 * statusCellMargin)
    
}
